package cn.huijielong.modules.pub.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.huijielong.common.utils.Query;
import cn.huijielong.common.validator.ValidatorUtils;
import cn.huijielong.common.validator.group.Group;
import cn.huijielong.modules.pub.dao.LocationDao;
import cn.huijielong.modules.pub.entity.LocationEntity;
import cn.huijielong.modules.pub.service.LocationService;
import cn.huijielong.modules.sys.service.impl.SimpleServiceImpl;



@Service("locationService")
public class LocationServiceImpl extends SimpleServiceImpl implements LocationService {
	@Autowired
	private LocationDao locationDao;
	
	@Override
	public LocationEntity queryObject(Long locationId){
		return locationDao.queryObject(locationId);
	}
	
	@Override
	public Page<LocationEntity> queryList(Query q){
	    Page<LocationEntity> page=PageHelper.startPage(q.getPage(), q.getLimit()).doSelectPage(()-> locationDao.queryList(q));
		return page;		
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return locationDao.queryTotal(map);
	}
	
	@Override
	public void save(LocationEntity location){
		ValidatorUtils.validateEntity(location, Group.class);
		locationDao.save(location);
	}
	
	@Override
	public void update(LocationEntity location){
		locationDao.update(location);
	}
	
	@Override
	public void delete(Long locationId){
		locationDao.delete(locationId);
	}
	
	@Override
	public void deleteBatch(Long[] locationIds){
		locationDao.deleteBatch(locationIds);
	}
	
}
